
<script>
    $(function () {
        let y = {{.total_used_traffic}};
        let z = {{.transfer_enable}};
        let t = 0;        
        if (z != 0) {
            t = (y/z)*100
        }
        if (t >= 80) {
            
        }
        $("#jdt").css("width",t + "%");
        $("#jdt").addClass('bg-warning');

        let expiredAt='{{.user.ExpiredAt}}';
        // 获取当前时间的日期对象
        let currentDate = new Date();

        // 将给定的日期字符串转换为日期对象
        let expirationDate = new Date(expiredAt);

        // 计算时间差（以毫秒为单位）
        let timeDifference = expirationDate - currentDate;

        // 计算5天的毫秒数
        let fiveDaysInMillis = 5 * 24 * 60 * 60 * 1000;

        if (timeDifference < fiveDaysInMillis) {
            $("#expired_at_id").css('color','red')
        } 

    })


    function myFunction(text) {
        let input_dom = document.createElement('input');
        input_dom.value = text;
        document.body.appendChild(input_dom);//向页面底部追加输入框
        input_dom.select();//选择input元素
        document.execCommand("Copy");//执行复制命令
        notify('success', "复制成功")
        input_dom.remove();//删除动态创建的节点
    }

   function xf(id) {
        Swal.fire({
            title: "确定?",
            text: "续费将覆盖当前订阅时长和流量！",
            icon: "question",
            confirmButtonText: "确定",
            showCancelButton: true,
            cancelButtonText: "取消",
        }).then((result) => {
            /* Read more about isConfirmed, isDenied below */
            if (result.isConfirmed) {
                location.href = "/user/plan_renew?id=" + id
            } 
        });

       
   }


</script>